<template>
	<view class="charge">
		<view class="top">
			<text class="toptext">金额</text>
			<view class="topinput">
				<!-- ￥<input type="number" placeholder="0.00" v-model="num" /> -->
				<text>￥3300</text>
				<text class="msg">充值可续费1年会员，并且可得3600余额</text>
			</view>
		</view>

		<view class="charge_1">
			<text class="title">付款方式</text>
			<view class="charge_check">
				<view class="left">
					<image src="/static/index/yh1.png" mode=""></image>
					<view class="text">
						<text>银行转账</text>

					</view>
				</view>
				<view class="right">
					<label class="radio">
						<radio @click="changeradio(1)" :checked="radioShow === 1" />
					</label>
				</view>
			</view>
			<view class="bankinfo" v-if="radioShow == 1">
				<view class="info">
					银行名称：{{bankinfo.bank_name}}
				</view>
				<view class="info bank_num">
					<text>银行卡号：{{bankinfo.bank_num}}</text><text @click="copy(bankinfo.bank_num)">复制</text>
				</view>
				<view class="info">
					开户姓名：{{bankinfo.bank_user}}
				</view>
			</view>
			<view class="charge_check">
				<view class="left">
					<image src="/static/index/wx.png" mode=""></image>
					<view class="text">
						<text>微信转账</text>

					</view>
				</view>
				<view class="right">
					<label class="radio">
						<radio @click="changeradio(2)" :checked="radioShow === 2" />
					</label>
				</view>
			</view>
			<view class="payimg" v-if="radioShow == 2">
				<image :src="getimg(bankinfo.wechat_code)" mode="widthFix"></image>
			</view>
			<view class="charge_check">
				<view class="left">
					<image src="/static/index/zfb.png" mode=""></image>
					<view class="text">
						<text>支付宝转账</text>

					</view>
				</view>
				<view class="right">
					<label class="radio">
						<radio @click="changeradio(3)" :checked="radioShow === 3" />
					</label>
				</view>
			</view>
			<view class="payimg" v-if="radioShow == 3">
				<image :src="getimg(bankinfo.ali_code)" mode="widthFix"></image>
			</view>

		</view>
		<view class="charge_1">
			<text class="title">支付凭证</text>
			<fjjImages :pageImgList="wximg" @getwximgurl="getwximgurl" :type="geturl[0]" :imgCount="1"
				@addImg="editParkImg" @deleteImg="deleteImg"></fjjImages>
		</view>
		<!-- <view class="bg" v-if="isSure">
			<view class="password">
				<view class="title">
					<text>请输入支付密码</text>
					<text @click="close">X</text>
				</view>
				<view class="password_input">
					<input type="password" v-model="password" placeholder="请输入支付密码"
						placeholder-style="font-size:14px;color:#777" />
				</view>
				<view class="getbtn">
					<view class="btn1" @click="sure">
						确认
					</view>
					<view class="btn2" @click="close">
						取消
					</view>
				</view>
			</view>
		</view> -->
		<view class="btn" @click="pay">
			确认充值
		</view>

	</view>
</template>

<script>
	import {
		checkLogin,
		loginOut
	} from '../../api/login.js'
	import {
		Recharge,
		GetRecharge
	} from '../../api/api.js'
	import fjjImages from '@/components/fjj-images/fjj-images.vue'
	export default {
		components: {
			fjjImages
		},
		data() {
			return {
				geturl: ['getwximgurl', 'getzfbimgurl'],
				radioShow: 1,
				wximg: [],
				num: '',
				isSure: false,
				info: [],
				bankinfo: [],
				to_type: ['', '银行', '微信', '支付宝'],
				password: ''
			}
		},
		onLoad() {
			this.checkLogin()
			this.GetRecharge()
		},
		methods: {
			checkLogin() {
				if (!checkLogin()){
					uni.redirectTo({
						url: '/pages/login/index'
					})
			}

		},
		copy(text) {
			uni.setClipboardData({
				data: text
			});
		},
		pay() {
			// this.isSure = true
			if (this.wximg[0] == undefined) {
				uni.showToast({
					title: '请上传支付凭证',
					icon: 'none'
				})
				return false
			}

			Recharge({
				num: this.num,
				type: this.radioShow,
				voucher_url: this.wximg[0]
			}).then(res => {
				uni.showToast({
					title: res.message,
					icon: 'none'
				})
				setTimeout(() => {
					if (res.status == 1) {
						uni.navigateBack()
					}
				}, 1000)
				// this.isSure = false
			})
		},
		sure() {

		},
		close() {
			this.password = ''
			this.isSure = false
		},
		getimg(url) {
			return this.websiteUrl + url
		},
		GetRecharge() {
			GetRecharge().then(res => {
				this.bankinfo = res.data
				console.log(res)
			})
		},
		getwximgurl(e) {
			this.wximg = e
			console.log(e)
		},
		changeradio(i) {
			this.radioShow = i
			console.log(this.radioShow)
		},
		editParkImg(currentTempFilePath) {},
		deleteImg(index) {},
	}
	}
</script>

<style lang="scss">
	.infolist {
		.title {
			display: flex;
			justify-content: space-between;

			view {
				width: 33%;
			}

		}

		.to_type {
			text-align: right;
		}

		.num {
			text-align: center;
		}

		.msg {
			.msgitem {
				view {
					width: 33%;
				}

				display: flex;
				justify-content: space-between;
				padding: 0 5%;
				line-height: 40px;
				font-size: 12px;
			}
		}
	}

	.charge {
		padding-bottom: 20rpx;

		.top {
			background: #fff;
			padding-bottom: 20px;

			.toptext {
				padding: 0 5%;
				line-height: 70px;
			}

			.topinput {
				display: flex;
				// align-items: center;
				flex-direction: column;
				font-size: 20px;
				padding: 0 5%;

				input {
					margin-left: 5px;
					font-size: 20px;
					border-bottom: 1px solid #ccc;
				}

				.msg {
					font-size: 10px;
					color: #1d3f2b;
					margin-top: 5px;
				}
			}
		}

		.title {
			padding: 0 5%;
			line-height: 40px;
			font-size: 12px;
		}

		.charge_1 {
			background: #fff;
			margin-top: 20rpx;

			.bankinfo {
				font-size: 24rpx;
				padding: 10rpx 5%;
				padding-bottom: 0;

				.info {
					padding: 20rpx 0;
					border-bottom: 1px solid #efefef;
				}

				.bank_num {
					display: flex;
					justify-content: space-between;
				}
			}

			.payimg {
				padding: 10px 0;

				image {
					width: 90%;
					margin-left: 5%;
				}
			}

			.charge_check {
				border-top: 1px solid #efefef;
				padding: 10px 10px;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.left {
					display: flex;
					align-items: center;

					image {
						width: 70rpx;
						height: 70rpx;
					}

					.text {
						display: flex;
						flex-direction: column;
						font-size: 12px;
						margin-left: 10px;

						.num {
							color: #777;
						}
					}
				}
			}
		}

		.btn {
			margin: 50px auto;
		}


		.bg {
			background: #00000033;
			position: absolute;
			top: 0;
			width: 100%;
			height: 100%;

			.password {
				background: #fff;
				position: absolute;
				width: 90%;
				left: 5%;
				top: 60vw;

				.title {
					display: flex;
					justify-content: space-between;
					padding: 4% 5%;
					font-size: 28rpx;
					background: #f8f8f8;
				}

				.password_input {
					border: 1px solid #ccc;
					width: 70%;
					margin: 70rpx auto;

					input {
						padding-left: 40rpx;
						height: 80rpx;
					}
				}

				.getbtn {
					display: flex;
					justify-content: flex-end;
					margin-top: 170rpx;
					padding-bottom: 40rpx;

					view {
						padding: 10rpx 30rpx;
						font-size: 28rpx;
					}

					.btn1 {
						background: #1E9FFF;
						color: #fff;
					}

					.btn2 {
						border: 1px solid #ccc;
						color: #777;
						margin: 0 40rpx;
					}
				}

			}
		}

	}
</style>
